/*用户我的会议JS*/

// 消息通知URL
var msgTableUrl;

// 处理消息URL
var dealMsgUrl;

// 会议列表URL
var confTableUrl;

// 相关会议URL
var confDetailUrl;

// 催办会议URL
var remindConfUrl;

// 修改会议URL
var alterConfUrl;

// 取消会议URL
var cancelConfUrl;

// 接受会议URL
var acceptConfUrl;

// 拒绝会议URL
var rejectConfUrl;

// 代替会议URL
var replaceConfUrl;

// 取得员工树形结构URL
var stafferTreeUrl;

// 消息通知列表
var msgTableId;

// 会议列表
var confTableId;

// 相关会议列表
var detailConfTableId;

// 会议日历控件id
var confCalendarId;

// 详细会议对话框
var detailConfDialog;

//员工树形结构
var stafferTreeId;

// 消息对话框
var messageDialog;

// 当前时间
var currentTime;

// 起始时间
var startTime;

// 终止时间
var endTime;

// 当前会议列列表选中数据
var selectedConfTableData;

// 当前会议列表选中行
var selectedConfTableRow;

/**
 *    设置消息通知URL
 */
function setMsgUrl(url) {
    msgTableUrl = url;
}

/**
 * 设置消息处理URL
 */
function setDealMsgUrl(url) {
    dealMsgUrl = url;
}

/**
 * 设置会议列表URL
 */
function setConfUrl(url) {
    confTableUrl = url;
}

/**
 * 设置相关会议URL
 */
function setConfDetailUrl(url) {
    confDetailUrl = url;
}

/**
 * 设置催办会议URL
 */
function setRemindConfUrl(url) {
    remindConfUrl = url;
}

/**
 * 设置修改会议URL
 */
function setAlterConfUrl(url) {
    alterConfUrl = url;
}

/**
 * 设置取消会议URL
 */
function setCancelConfUrl(url) {
    cancelConfUrl = url;
}

/**
 * 设置接受会议URL
 */
function setAcceptConfUrl(url) {
    acceptConfUrl = url;
}

/**
 * 设置拒绝会议URL
 */
function setRejectConfUrl(url) {
    rejectConfUrl = url;
}

/**
 * 设置代替会议URL
 */
function setReplaceConfUrl(url) {
    replaceConfUrl = url;
}

/**
 * 设置消息通知列表
 */
function setMsgTable(id) {
    msgTableId = id;
}

/**
 *    设置会议列表
 */
function setConfTable(id) {

    // 取得会议列表ID
    confTableId = id;

    // 会议列表行选中事件
    $(confTableId).bind("rowselected", function (event, data, row) {
        confId = data.id;
        selectedConfTableData = data;
        selectedConfTableRow = row;
        $(confCalendarId).selectedConference({data: selectedConfTableData});
        data = getConfDetailData(confDetailUrl, confId);
        createDetailConfTable(data);
    });
}

function setDetailConfTable(id) {

    // 取得详细会议列表ID
    detailConfTableId = id;
}

/**
 * 设置会议列表URL
 */
function setConfCalendar(id) {
    confCalendarId = id;

    // 点击前一周时间事件
    $(confCalendarId).bind("selectPrevDate", function (event, time1, time2) {
        startTime = time1;
        endTime = time2;
        refreshUserConference();
    });

    // 点击后一周时间事件
    $(confCalendarId).bind("selectNextDate", function (event, time1, time2) {
        startTime = time1;
        endTime = time2;
        refreshUserConference();
    });
}

/**
 * 设置会议审批对话框
 */
function setDetailConfDialog(id) {
    detailConfDialog = id;
    $(detailConfDialog).initCustomDialog({
        title: "相关会议",
        width: 600,
        height: 580,
        modal: true
    });
    $(detailConfDialog).bind("btnClick", function (event, name, value) {
        _this = $(this);
        var id = value;
        var remark = $(detailConfDialog).find("#remark").val();
        switch (name) {
            case "审批催办":
                _this.dialog("close");
                var result = remindConf(remindConfUrl, id, null, remark);
                if (result != null && result != "ERROR_RES_02") {
                    $(messageDialog).openMessageDialog({message: "操作成功"});
                } else {
                    $(messageDialog).openMessageDialog({message: "操作失败,CODE:" + result});
                }
                break;
            case "参会催办":
                var data = getStafferTree(stafferTreeUrl);
                $(stafferTreeId).initTree({
                    title: "选择参会人员",
                    width: 350,
                    height: 450,
                    data: data,
                    modal: false
                });
                $(stafferTreeId).openTree();
                $(stafferTreeId).bind("selectedTree", function (event, name, value) {
                    $(this).unbind();
                    _this.dialog("close");
                    var result = remindConf(remindConfUrl, id, value, remark);
                    if (result != null && result != "ERROR_RES_02") {
                        $(messageDialog).openMessageDialog({message: "操作成功"});
                    } else {
                        $(messageDialog).openMessageDialog({message: "操作失败,CODE:" + result});
                    }
                });
                break;
            case "修改会议":
                _this.dialog("close");
                location.href = "/foc/user/conferencebook/modifyConference?id=" + id;
                break;
            case "取消会议":
                if ($(this).find("#remark").val() == null || $(this).find("#remark").val() == "") {
                    $(this).find("#remarkWarning").show();
                } else {
                    _this.dialog("close");
                    var result = cancelConf(cancelConfUrl, id, remark);
                    if (result != null && result != "ERROR_RES_02") {
                        $(messageDialog).openMessageDialog({message: "操作成功"});
                        refreshUserConference();
                        data = getConfDetailData(confDetailUrl, result);
                        createDetailConfTable(data);
                    } else {
                        $(messageDialog).openMessageDialog({message: "操作失败,CODE:" + result});
                    }
                }
                break;
            case "接受参会":
                _this.dialog("close");
                var result = acceptConf(acceptConfUrl, id, remark);
                if (result != null && result != "ERROR_RES_02") {
                    $(messageDialog).openMessageDialog({message: "操作成功"});
                    refreshUserConference();
                    data = getConfDetailData(confDetailUrl, result);
                    createDetailConfTable(data);
                } else {
                    $(messageDialog).openMessageDialog({message: "操作失败,CODE:" + result});
                }
                break;
            case "拒绝参会":
                if ($(this).find("#remark").val() == null || $(this).find("#remark").val() == "") {
                    $(this).find("#remarkWarning").show();
                } else {
                    _this.dialog("close");
                    var result = rejectConf(rejectConfUrl, id, remark);
                    if (result != null && result != "ERROR_RES_02") {
                        $(messageDialog).openMessageDialog({message: "操作成功"});
                        refreshUserConference();
                        data = getConfDetailData(confDetailUrl, result);
                        createDetailConfTable(data);
                    } else {
                        $(messageDialog).openMessageDialog({message: "操作失败,CODE:" + result});
                    }
                }
                break;
            case "代替参会":
                if ($(this).find("#remark").val() == null || $(this).find("#remark").val() == "") {
                    $(this).find("#remarkWarning").show();
                } else {
                    var data = getStafferTree(stafferTreeUrl);
                    $(stafferTreeId).initTree({
                        title: "选择参会人员",
                        width: 350,
                        height: 450,
                        data: data,
                        multiSelected: false,
                        modal: false
                    });
                    $(stafferTreeId).openTree();
                    $(stafferTreeId).bind("selectedTree", function (event, name, value) {
                        _this.dialog("close");
                        var result = replaceConf(replaceConfUrl, id, value, remark);
                        if (result != null && result != "ERROR_RES_02") {
                            $(messageDialog).openMessageDialog({message: "操作成功"});
                            refreshUserConference();
                            data = getConfDetailData(confDetailUrl, result);
                            createDetailConfTable(data);
                        } else {
                            $(messageDialog).openMessageDialog({message: "操作失败,CODE:" + result});
                        }
                    });
                }
                break;
            default:
                break;
        }
    });
}

/**
 * 设置员工树形控件
 */
function setStafferTree(id, url) {
    stafferTreeId = id;
    stafferTreeUrl = url;
}

/**
 * 设置消息对话框
 * @param id
 */
function setMessageDialog(id) {
    messageDialog = id;
    $(messageDialog).messagedialog({
        title: "提示",
        type: 0,
        width: 400,
        height: 300,
        modal: true
    });
}

/**
 * 初始化我的会议JS
 */
function initUserConference(interval) {
    if (interval == null || interval.length == 0) {
        interval = 5000;
    }
    if (currentTime == null) {
        currentTime = new Date();
        startTime = getStartTime(currentTime);
        endTime = getEndTime(currentTime);
    }
    $(confCalendarId).setNavigateDate({
        startTime: startTime,
        endTime: endTime
    });
    data = getMsgTableData(msgTableUrl);
    createMsgTable(data);
    data = getConfTableData(confTableUrl);
    createConfTable(data);
    $(confCalendarId).drewWeekCalendar({data: data});
    setInterval(function () {
        data = getMsgTableData(msgTableUrl);
        createMsgTable(data);
        data = getConfTableData(confTableUrl);
        createConfTable(data);
        $(confCalendarId).drewWeekCalendar({data: data});
        if (selectedConfTableData != null) {
            selectedConfTableRow = getSelectedRow(confTableId, selectedConfTableData.id);
            if (selectedConfTableRow != null && selectedConfTableRow != "") {
                $(confTableId).setSelectedRow({
                    rowNumber: selectedConfTableRow
                });
                $(confCalendarId).selectedConference({data: selectedConfTableData});
                data = getConfDetailData(confDetailUrl, selectedConfTableData.id);
                createDetailConfTable(data);
            } else {
                selectedConfTableData = null;
                createDetailConfTable(null);
            }
        }
    }, interval);
}

/**
 * 点击消息导航
 */
function navigateConfInfo(date) {
    date = new Date(Date.parse(date.replace(/-/g, "/")));
    startTime = getStartTime(date);
    endTime = getEndTime(date);
    $(confCalendarId).setNavigateDate({
        startTime: startTime,
        endTime: endTime
    });
    refreshUserConference();
}

/**
 * 取得消息数据
 */
function getMsgTableData(url) {
    try {
        var obj = $.ajax({
            url: url,
            async: false,
            timeout: 60000
        }).responseText;
        return $.parseJSON(obj);
    } catch (e) {
        return null;
    }
}

/**
 * 处理消息
 */
function dealMsgData(url, id) {
    try {
        var obj = $.ajax({
            url: url,
            async: false,
            timeout: 60000,
            data: {id: id}
        }).responseText;
        return obj;
    } catch (e) {
        return null;
    }
}

/**
 * 取得会议列表数据
 */
function getConfTableData(url) {
    try {
        var obj = $.ajax({
            url: url,
            async: false,
            timeout: 60000,
            data: {startTime: startTime, endTime: endTime}
        }).responseText;
        return $.parseJSON(obj);
    } catch (e) {
        return null;
    }
}

/**
 * 取得相关会议数据
 */
function getConfDetailData(url, id) {
    try {
        var obj = $.ajax({
            url: url,
            async: false,
            timeout: 60000,
            data: {id: id}
        }).responseText;
        return $.parseJSON(obj);
    } catch (e) {
        return null;
    }
}

/**
 * 催办会议
 */
function remindConf(url, id, staffer, remark) {
    try {
        var obj = $.ajax({
            url: url,
            async: false,
            timeout: 60000,
            data: {id: id, staffer: staffer, remark: remark}
        }).responseText;
        return obj;
    } catch (e) {
        return null;
    }
}

/**
 * 用户取消会议
 */
function cancelConf(url, id, remark) {
    try {
        var obj = $.ajax({
            url: url,
            async: false,
            timeout: 60000,
            data: {id: id, remark: remark}
        }).responseText;
        return obj;
    } catch (e) {
        return null;
    }
}

/**
 * 用户接受会议
 */
function acceptConf(url, id, remark) {
    try {
        var obj = $.ajax({
            url: url,
            async: false,
            timeout: 60000,
            data: {id: id, remark: remark}
        }).responseText;
        return obj;
    } catch (e) {
        return null;
    }
}

/**
 * 用户拒绝会议
 */
function rejectConf(url, id, remark) {
    try {
        var obj = $.ajax({
            url: url,
            async: false,
            timeout: 60000,
            data: {id: id, remark: remark}
        }).responseText;
        return obj;
    } catch (e) {
        return null;
    }
}

/**
 * 用户代替会议
 */
function replaceConf(url, id, staffer, remark) {
    try {
        var obj = $.ajax({
            url: url,
            async: false,
            timeout: 60000,
            data: {id: id, staffer: staffer, remark: remark}
        }).responseText;
        return obj;
    } catch (e) {
        return null;
    }
}

/**
 * 创建消息列表
 */
function createMsgTable(data) {
    if ($(msgTableId).find("li") != null) {
        $(msgTableId).find("li").remove();
    }
    if (data != null) {
        for (var i = 0; i < data.length; i++) {
            $(msgTableId).append("<li></li>");
            $(msgTableId).find("li").eq(i).append("<div><div title='" + data[i].content + "' style='width:85%;float:left;max-width:400px;white-space:nowrap;overflow-x:hidden ; text-overflow:ellipsis; '><a href='#' >"
                + data[i].content + "</a></div><div style='float:right;'><a><img src='/foc/resources/images/user/chuli.png' border='0' /></a></div></div>");
            $(msgTableId).find("li").eq(i).find("a").eq(0).click([data[i].conferenceTime], function (event) {
                navigateConfInfo(event.data.toString());
            });
            $(msgTableId).find("li").eq(i).find("a").eq(1).click([data[i].id], function (event) {
                if ($(this).find("img").attr("src") == "/foc/resources/images/user/chuli_1.png") {
                    return;
                }
                msgId = event.data;
                var result = dealMsgData(dealMsgUrl, msgId.toString());
                if (result == "SER_RES_SUCCESS") {
                    $(this).find("img").attr("src", "/foc/resources/images/user/chuli_1.png");
                }
            });
        }
    }
}

/**
 * 创建会议列表
 */
function createConfTable(data) {
    if ($(confTableId).find(".middle_2_bottom_table_1") != null) {
        $(confTableId).find(".middle_2_bottom_table_1").remove();
    }
    if (data != null) {
        for (var i = 0; i < data.length; i++) {
            $(confTableId).append("<tr class='middle_2_bottom_table_1'></tr>");
            $(confTableId).find("tr").eq(i + 1).append("<td style='border-left: #818080 solid 1px;'>" + (i + 1) + "<input type='hidden' value='" + data[i].id + "'/>" + "</td>");
            $(confTableId).find("tr").eq(i + 1).append("<td>" + data[i].conferenceTime + "</td>");
            $(confTableId).find("tr").eq(i + 1).append("<td>" + data[i].meetingName + "</td>");
            $(confTableId).find("tr").eq(i + 1).append("<td>" + data[i].boardroom + "</td>");
            $(confTableId).find("tr").eq(i + 1).append("<td>" + data[i].stafferCount + "</td>");
            $(confTableId).find("tr").eq(i + 1).append("<td>" + data[i].flag + "</td>");
            if (data[i].status == "0") {
                $(confTableId).find("tr").eq(i + 1).append("<td>预定中</td>");
            } else if (data[i].status == "1" || data[i].status == "3") {
                $(confTableId).find("tr").eq(i + 1).append("<td>已预订</td>");
            } else if (data[i].status == "2" || data[i].status == "4") {
                $(confTableId).find("tr").eq(i + 1).append("<td>已审批</td>");
            } else if (data[i].status == "5") {
                $(confTableId).find("tr").eq(i + 1).append("<td>已取消</td>");
            } else if (data[i].status == "6") {
                $(confTableId).find("tr").eq(i + 1).append("<td>已结束</td>");
            } else if (data[i].status == "7") {
                $(confTableId).find("tr").eq(i + 1).append("<td>已接受</td>");
            }
        }
    }
    $(confTableId).initDataTable({
        rowSelected: true,
        data: data
    });
}

/**
 * 创建相关会议列表
 */
function createDetailConfTable(data) {
    if ($(detailConfTableId).find("li") != null) {
        $(detailConfTableId).find("li").remove();
    }
    var confData = data;
    if (confData != null) {
        for (var i = 0; i < confData.length; i++) {
            $(detailConfTableId).append("<li class='middle_2_top_2_li'></li>");
            $(detailConfTableId).find("li").eq(i).append("<div class='middle_2_top_list'></div>");
            switch (confData[i].status) {
                case "0":
                    $(detailConfTableId).find("li").eq(i).find(".middle_2_top_list").append("<div class='middle_2_top_list_1_space'></div><div class='middle_2_top_list_1_block'></div><div class='middle_2_top_list_1'></div>");
                    $(detailConfTableId).find("li").eq(i).find(".middle_2_top_list_1_block").addClass("calendar-booking");
                    $(detailConfTableId).find("li").eq(i).find(".middle_2_top_list_1").addClass("calendar-booking-color");
                    break;
                case "1":
                    $(detailConfTableId).find("li").eq(i).find(".middle_2_top_list").append("<div class='middle_2_top_list_1_space'></div><div class='middle_2_top_list_1_block'></div><div class='middle_2_top_list_1'></div>");
                    $(detailConfTableId).find("li").eq(i).find(".middle_2_top_list_1_block").addClass("calendar-book");
                    $(detailConfTableId).find("li").eq(i).find(".middle_2_top_list_1").addClass("calendar-book-color");
                    break;
                case "2":
                    $(detailConfTableId).find("li").eq(i).find(".middle_2_top_list").append("<div class='middle_2_top_list_1_space'></div><div class='middle_2_top_list_1_block'></div><div class='middle_2_top_list_1'></div>");
                    $(detailConfTableId).find("li").eq(i).find(".middle_2_top_list_1_block").addClass("calendar-approval");
                    $(detailConfTableId).find("li").eq(i).find(".middle_2_top_list_1").addClass("calendar-approval-color");
                    break;
                case "3":
                    $(detailConfTableId).find("li").eq(i).find(".middle_2_top_list").append("<div class='middle_2_top_list_1_space'></div><div class='middle_2_top_list_1_block'></div><div class='middle_2_top_list_1'></div>");
                    $(detailConfTableId).find("li").eq(i).find(".middle_2_top_list_1_block").addClass("calendar-important-book");
                    $(detailConfTableId).find("li").eq(i).find(".middle_2_top_list_1").addClass("calendar-important-book-color");
                    break;
                case "4":
                    $(detailConfTableId).find("li").eq(i).find(".middle_2_top_list").append("<div class='middle_2_top_list_1_space'></div><div class='middle_2_top_list_1_block'></div><div class='middle_2_top_list_1'></div>");
                    $(detailConfTableId).find("li").eq(i).find(".middle_2_top_list_1_block").addClass("calendar-important-approval");
                    $(detailConfTableId).find("li").eq(i).find(".middle_2_top_list_1").addClass("calendar-important-approval-color");
                    break;
                case "5":
                    $(detailConfTableId).find("li").eq(i).find(".middle_2_top_list").append("<div class='middle_2_top_list_1_space'></div><div class='middle_2_top_list_1_block'></div><div class='middle_2_top_list_1'></div>");
                    $(detailConfTableId).find("li").eq(i).find(".middle_2_top_list_1_block").addClass("calendar-cancel");
                    $(detailConfTableId).find("li").eq(i).find(".middle_2_top_list_1").addClass("calendar-cancel-color");
                    break;
                case "6":
                    $(detailConfTableId).find("li").eq(i).find(".middle_2_top_list").append("<div class='middle_2_top_list_1_space'></div><div class='middle_2_top_list_1_block'></div><div class='middle_2_top_list_1'></div>");
                    $(detailConfTableId).find("li").eq(i).find(".middle_2_top_list_1_block").addClass("calendar-finish");
                    $(detailConfTableId).find("li").eq(i).find(".middle_2_top_list_1").addClass("calendar-finish-color");
                    break;
                case "7":
                    $(detailConfTableId).find("li").eq(i).find(".middle_2_top_list").append("<div class='middle_2_top_list_1_space'></div><div class='middle_2_top_list_1_block'></div><div class='middle_2_top_list_1'></div>");
                    $(detailConfTableId).find("li").eq(i).find(".middle_2_top_list_1_block").addClass("calendar-accept");
                    $(detailConfTableId).find("li").eq(i).find(".middle_2_top_list_1").addClass("calendar-accept-color");
                    break;
                default:
                    break;
            }
            $(detailConfTableId).find("li").eq(i).find(".middle_2_top_list_1").append(confData[i].meetingName);
            $(detailConfTableId).find("li").eq(i).find(".middle_2_top_list").append("<div class='middle_2_top_list_2'></div>");
            $(detailConfTableId).find("li").eq(i).find(".middle_2_top_list_2").append("会议时间:&nbsp;" + confData[i].conferenceTime + "&nbsp;&nbsp;&nbsp;&nbsp;会议级别:&nbsp;" + confData[i].flag + "<br/>" + "会议地点:&nbsp;" + confData[i].boardroom + "&nbsp;&nbsp;&nbsp;&nbsp;参会人数:&nbsp;" + confData[i].stafferCount);
            if (selectedConfTableData != null) {
                if (confData[i].id == selectedConfTableData.id) {
                    $(detailConfTableId).find("li").eq(i).addClass("middle_2_top_list_1_selected");
                }
            }
            $(detailConfTableId).find("li").eq(i).find(".middle_2_top_list").mouseenter(function () {
                $(this).addClass("hover");
            });
            $(detailConfTableId).find("li").eq(i).find(".middle_2_top_list").mouseleave(function () {
                $(this).removeClass("hover");
            });
            $(detailConfTableId).find("li").eq(i).find(".middle_2_top_list").click([confData[i]], function (event) {
                confData = event.data[0];
                if (confData.booking == 1) {
                    if (confData.status == "0") {
                        $(detailConfDialog).initCustomDialog({
                            title: "相关会议",
                            width: 600,
                            height: 580,
                            button1: "会议催办",
                            disabled1: true,
                            button2: "修改会议",
                            data2: confData.id,
                            disabled2: false,
                            button3: "取消会议",
                            data3: confData.id,
                            disabled3: false,
                            buttonSize: 3,
                            auto: false,
                            modal: true
                        });
                    } else if (confData.status == "1" || confData.status == "3") {
                        $(detailConfDialog).initCustomDialog({
                            title: "相关会议",
                            width: 600,
                            height: 580,
                            button1: "审批催办",
                            data1: confData.id,
                            disabled1: false,
                            button2: "修改会议",
                            data2: confData.id,
                            disabled2: false,
                            button3: "取消会议",
                            data3: confData.id,
                            disabled3: false,
                            buttonSize: 3,
                            auto: false,
                            modal: true
                        });
                    } else if (confData.status == "2" || confData.status == "4") {
                        $(detailConfDialog).initCustomDialog({
                            title: "相关会议",
                            width: 600,
                            height: 580,
                            button1: "参会催办",
                            data1: confData.id,
                            disabled1: false,
                            button2: "修改会议",
                            data2: confData.id,
                            disabled2: false,
                            button3: "取消会议",
                            data3: confData.id,
                            disabled3: false,
                            buttonSize: 3,
                            auto: false,
                            modal: true
                        });
                    } else {
                        $(detailConfDialog).initCustomDialog({
                            title: "相关会议",
                            width: 600,
                            height: 580,
                            button1: "会议催办",
                            disabled1: true,
                            button2: "修改会议",
                            disabled2: true,
                            button3: "取消会议",
                            disabled3: true,
                            buttonSize: 3,
                            modal: true
                        });
                    }
                } else {
                    if (confData.status == "2" || confData.status == "4") {
                        $(detailConfDialog).initCustomDialog({
                            title: "相关会议",
                            width: 600,
                            height: 580,
                            button1: "接受参会",
                            data1: confData.id,
                            disabled1: false,
                            button2: "拒绝参会",
                            data2: confData.id,
                            disabled2: false,
                            button3: "代替参会",
                            data3: confData.id,
                            disabled3: false,
                            buttonSize: 3,
                            auto: false,
                            modal: true
                        });
                    } else if (confData.status == "7") {
                        $(detailConfDialog).initCustomDialog({
                            title: "相关会议",
                            width: 600,
                            height: 580,
                            button1: "接受参会",
                            disabled1: true,
                            button2: "拒绝参会",
                            data2: confData.id,
                            disabled2: false,
                            button3: "代替参会",
                            data3: confData.id,
                            disabled3: false,
                            buttonSize: 3,
                            auto: false,
                            modal: true
                        });
                    } else {
                        $(detailConfDialog).initCustomDialog({
                            title: "相关会议",
                            width: 600,
                            height: 580,
                            button1: "接受参会",
                            disabled1: true,
                            button2: "拒绝参会",
                            disabled2: true,
                            button3: "代替参会",
                            disabled3: true,
                            buttonSize: 3,
                            modal: true
                        });
                    }
                }
                $(detailConfDialog).openCustomDialog();
                $(detailConfDialog).find("#meetingname").val(confData.meetingName);
                $(detailConfDialog).find("#boardroom").val(confData.boardroom);
                $(detailConfDialog).find("#meetingtime").val(confData.conferenceTime);
                $(detailConfDialog).find("#project").val(confData.project);
                $(detailConfDialog).find("#flag").val(confData.flag);
                $(detailConfDialog).find("#secretlevel").val(confData.secretLevel);
                $(detailConfDialog).find("#originator").val(confData.originator.stafferName);
                $(detailConfDialog).find("#telephone").val(confData.originator.telphone);
                $(detailConfDialog).find("#moderator").val(confData.moderator);
                $(detailConfDialog).find("#staffercount").val(confData.stafferCount);
                $(detailConfDialog).find("#staffer").val(confData.staffer);
                $(detailConfDialog).find("#remark").val("");
                $(detailConfDialog).find("#remarkWarning").hide();
            });
        }
    }
}

/**
 * 获取列表选中行
 */
function getSelectedRow(id, confId) {
    var count = $(id).find(".middle_2_bottom_table_1").length;
    for (var i = 0; i < count; i++) {
        if (confId == $(id).find(".middle_2_bottom_table_1").eq(i).find("td").eq(0).find("input").val()) {
            row = i + 1;
            return row;
        }
    }
}

/**
 * 设置会议室默认状态
 */
function refreshUserConference() {

    // 刷新会议列表
    data = getConfTableData(confTableUrl);
    createConfTable(data);

    // 刷新会议日历
    $(confCalendarId).drewWeekCalendar({data: data});

    // 刷新相关会议
    if ($(detailConfTableId).find("li") != null) {
        $(detailConfTableId).find("li").remove();
    }
}

/**
 * 获取起始时间
 */
function getStartTime(dt) {
    var startTime = dt;
    var day = dt.getDay();
    switch (day) {
        case 0:
            startTime.setDate(startTime.getDate() - 6);
            break;
        case 2:
            startTime.setDate(startTime.getDate() - 1);
            break;
        case 3:
            startTime.setDate(startTime.getDate() - 2);
            break;
        case 4:
            startTime.setDate(startTime.getDate() - 3);
            break;
        case 5:
            startTime.setDate(startTime.getDate() - 4);
            break;
        case 6:
            startTime.setDate(startTime.getDate() - 5);
            break;
        default:
            break;
    }
    return formatDate(startTime) + " 00:00:00";
}

/**
 * 获取终止时间
 */
function getEndTime(dt) {
    var endTime = dt;
    var day = dt.getDay();
    switch (day) {
        case 1:
            endTime.setDate(endTime.getDate() + 6);
            break;
        case 2:
            endTime.setDate(endTime.getDate() + 5);
            break;
        case 3:
            endTime.setDate(endTime.getDate() + 4);
            break;
        case 4:
            endTime.setDate(endTime.getDate() + 3);
            break;
        case 5:
            endTime.setDate(endTime.getDate() + 2);
            break;
        case 6:
            endTime.setDate(endTime.getDate() + 1);
            break;
        default:
            break;
    }
    return formatDate(endTime) + " 23:59:59";
}

/**
 * 格式化日期
 */
function formatDate(dt) {
    var curYear = dt.getFullYear();
    var curMonth = (dt.getMonth() + 1);
    if (curMonth < 10) {
        curMonth = "0" + curMonth;
    }
    var curDay = dt.getDate();
    if (curDay < 10) {
        curDay = "0" + curDay;
    }
    return curYear + "-" + curMonth + "-" + curDay;
}